#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
map<LL, LL> cha;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
int m, n, k;
LL getNum(int x, int y) {
    if (x>=m || x<0 || y>=n || y<0) return -1;
    return x*(n+2) + y;
}

void add(LL a, LL b) {
    while (cha[a] != a) a = cha[a];
    while (b != cha[b]) b = cha[b];
    cha[b] = a;
}

int main() {
#ifdef hai
    freopen("in.txt", "r", stdin);
#endif
    while (cin>>m>>n>>k) {
        int x, y;
        int xx, yy;
        int res = 0;
        cha.clear();
        for (int i=0; i<k; ++i) {
            scanf("%d %d", &x, &y);
            LL biao1 = getNum(x, y);
            if (biao1 == -1) {
                printf("%d ", res);
                continue;
            }
            if (!cha.count(biao1)) {
                ++res;
                cha[biao1] = biao1;
            }
            for (int j=0; j<4; ++j) {
                xx = x + dx[j]; yy = y + dy[j];
                LL biao = getNum(xx, yy);
                if (biao == -1) continue;
                if (!cha.count(biao)) continue;
                if (cha[biao] != cha[biao1]) {
                    --res;
                    add(biao, biao1);
                }
            }
//            printf("after cha[%d, %d]: %lld\n", x, y, cha[biao1]);
//            for (int j=0; j<4; ++j) {
//                xx = x + dx[j]; yy = y + dy[j];
//                LL biao = getNum(xx, yy);
//                if (biao == -1) continue;
//                if (!cha.count(biao)) continue;
//                printf("after cha[%d, %d]: %lld\n", xx, yy, cha[biao]);
//            }
            printf("%d ", res);
        }
        printf("\n");
    }
    return 0;
}
